<!-- HTML header for doxygen 1.8.6-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.13"/>
<title>OpenCV: High level stitching API (Stitcher class)</title>
<link href="../../opencv.ico" rel="shortcut icon" type="image/x-icon" />
<link href="../../tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="../../jquery.js"></script>
<script type="text/javascript" src="../../dynsections.js"></script>
<script type="text/javascript" src="../../tutorial-utils.js"></script>
<link href="../../search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="../../search/searchdata.js"></script>
<script type="text/javascript" src="../../search/search.js"></script>
<script type="text/x-mathjax-config">
  MathJax.Hub.Config({
    extensions: ["tex2jax.js", "TeX/AMSmath.js", "TeX/AMSsymbols.js"],
    jax: ["input/TeX","output/HTML-CSS"],
});
//<![CDATA[
MathJax.Hub.Config(
{
  TeX: {
      Macros: {
          matTT: [ "\\[ \\left|\\begin{array}{ccc} #1 & #2 & #3\\\\ #4 & #5 & #6\\\\ #7 & #8 & #9 \\end{array}\\right| \\]", 9],
          fork: ["\\left\\{ \\begin{array}{l l} #1 & \\mbox{#2}\\\\ #3 & \\mbox{#4}\\\\ \\end{array} \\right.", 4],
          forkthree: ["\\left\\{ \\begin{array}{l l} #1 & \\mbox{#2}\\\\ #3 & \\mbox{#4}\\\\ #5 & \\mbox{#6}\\\\ \\end{array} \\right.", 6],
          forkfour: ["\\left\\{ \\begin{array}{l l} #1 & \\mbox{#2}\\\\ #3 & \\mbox{#4}\\\\ #5 & \\mbox{#6}\\\\ #7 & \\mbox{#8}\\\\ \\end{array} \\right.", 8],
          vecthree: ["\\begin{bmatrix} #1\\\\ #2\\\\ #3 \\end{bmatrix}", 3],
          vecthreethree: ["\\begin{bmatrix} #1 & #2 & #3\\\\ #4 & #5 & #6\\\\ #7 & #8 & #9 \\end{bmatrix}", 9],
          cameramatrix: ["#1 = \\begin{bmatrix} f_x & 0 & c_x\\\\ 0 & f_y & c_y\\\\ 0 & 0 & 1 \\end{bmatrix}", 1],
          distcoeffs: ["(k_1, k_2, p_1, p_2[, k_3[, k_4, k_5, k_6 [, s_1, s_2, s_3, s_4[, \\tau_x, \\tau_y]]]]) \\text{ of 4, 5, 8, 12 or 14 elements}"],
          distcoeffsfisheye: ["(k_1, k_2, k_3, k_4)"],
          hdotsfor: ["\\dots", 1],
          mathbbm: ["\\mathbb{#1}", 1],
          bordermatrix: ["\\matrix{#1}", 1]
      }
  }
}
);
//]]>
</script><script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js"></script>
<link href="../../doxygen.css" rel="stylesheet" type="text/css" />
<link href="../../stylesheet.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<!--#include virtual="/google-search.html"-->
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectlogo"><img alt="Logo" src="../../opencv-logo-small.png"/></td>
  <td style="padding-left: 0.5em;">
   <div id="projectname">OpenCV
   &#160;<span id="projectnumber">4.5.2</span>
   </div>
   <div id="projectbrief">Open Source Computer Vision</div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.13 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "../../search",false,'Search');
</script>
<script type="text/javascript" src="../../menudata.js"></script>
<script type="text/javascript" src="../../menu.js"></script>
<script type="text/javascript">
$(function() {
  initMenu('../../',true,false,'search.php','Search');
  $(document).ready(function() { init_search(); });
});
</script>
<div id="main-nav"></div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div id="nav-path" class="navpath">
  <ul>
<li class="navelem"><a class="el" href="../../d9/df8/tutorial_root.html">OpenCV Tutorials</a></li><li class="navelem"><a class="el" href="../../d3/dd5/tutorial_table_of_content_other.html">Other tutorials (ml, objdetect, photo, stitching, video)</a></li>  </ul>
</div>
</div><!-- top -->
<div class="header">
  <div class="headertitle">
<div class="title">High level stitching API (Stitcher class) </div>  </div>
</div><!--header-->
<div class="contents">
<div class="textblock"><p><b>Prev Tutorial:</b> <a class="el" href="../../d3/db7/tutorial_hdr_imaging.html">High Dynamic Range Imaging</a></p>
<p><b>Next Tutorial:</b> <a class="el" href="../../d1/dc5/tutorial_background_subtraction.html">How to Use Background Subtraction Methods</a></p>
<table class="doxtable">
<tr>
<th align="right"></th><th align="left"></th></tr>
<tr>
<td align="right">Original author </td><td align="left">Jiri Horner </td></tr>
<tr>
<td align="right">Compatibility </td><td align="left">OpenCV &gt;= 3.2 </td></tr>
</table>
<h2>Goal </h2>
<p>In this tutorial you will learn how to:</p>
<ul>
<li>use the high-level stitching API for stitching provided by<ul>
<li><a class="el" href="../../d2/d8d/classcv_1_1Stitcher.html">cv::Stitcher</a></li>
</ul>
</li>
<li>learn how to use preconfigured Stitcher configurations to stitch images using different camera models.</li>
</ul>
<h2>Code </h2>
<p>This tutorial code's is shown lines below. You can also download it from <a href="https://github.com/opencv/opencv/tree/master/samples/cpp/stitching.cpp">here</a>.</p>
<div class="fragment"><div class="line"></div><div class="line"><span class="preprocessor">#include &quot;<a class="code" href="../../d6/d87/imgcodecs_8hpp.html">opencv2/imgcodecs.hpp</a>&quot;</span></div><div class="line"><span class="preprocessor">#include &quot;<a class="code" href="../../d4/dd5/highgui_8hpp.html">opencv2/highgui.hpp</a>&quot;</span></div><div class="line"><span class="preprocessor">#include &quot;<a class="code" href="../../dc/d7a/stitching_8hpp.html">opencv2/stitching.hpp</a>&quot;</span></div><div class="line"></div><div class="line"><span class="preprocessor">#include &lt;iostream&gt;</span></div><div class="line"></div><div class="line"><span class="keyword">using namespace </span>std;</div><div class="line"><span class="keyword">using namespace </span><a class="code" href="../../d2/d75/namespacecv.html">cv</a>;</div><div class="line"></div><div class="line"><span class="keywordtype">bool</span> divide_images = <span class="keyword">false</span>;</div><div class="line"><a class="code" href="../../d2/d8d/classcv_1_1Stitcher.html#a114713924ec05a0309f4df7e918c0324">Stitcher::Mode</a> mode = Stitcher::PANORAMA;</div><div class="line">vector&lt;Mat&gt; imgs;</div><div class="line"><span class="keywordtype">string</span> result_name = <span class="stringliteral">&quot;result.jpg&quot;</span>;</div><div class="line"></div><div class="line"><span class="keywordtype">void</span> printUsage(<span class="keywordtype">char</span>** argv);</div><div class="line"><span class="keywordtype">int</span> parseCmdArgs(<span class="keywordtype">int</span> argc, <span class="keywordtype">char</span>** argv);</div><div class="line"></div><div class="line"><span class="keywordtype">int</span> main(<span class="keywordtype">int</span> argc, <span class="keywordtype">char</span>* argv[])</div><div class="line">{</div><div class="line">    <span class="keywordtype">int</span> retval = parseCmdArgs(argc, argv);</div><div class="line">    <span class="keywordflow">if</span> (retval) <span class="keywordflow">return</span> EXIT_FAILURE;</div><div class="line"></div><div class="line">    <a class="code" href="../../d3/d63/classcv_1_1Mat.html">Mat</a> pano;</div><div class="line">    <a class="code" href="../../dc/d84/group__core__basic.html#ga6395ca871a678020c4a31fadf7e8cc63">Ptr&lt;Stitcher&gt;</a> stitcher = Stitcher::create(mode);</div><div class="line">    <a class="code" href="../../d2/d8d/classcv_1_1Stitcher.html#a507409ce9435dd89857469d12ec06b45">Stitcher::Status</a> status = stitcher-&gt;stitch(imgs, pano);</div><div class="line"></div><div class="line">    <span class="keywordflow">if</span> (status != Stitcher::OK)</div><div class="line">    {</div><div class="line">        cout &lt;&lt; <span class="stringliteral">&quot;Can&#39;t stitch images, error code = &quot;</span> &lt;&lt; int(status) &lt;&lt; endl;</div><div class="line">        <span class="keywordflow">return</span> EXIT_FAILURE;</div><div class="line">    }</div><div class="line"></div><div class="line">    <a class="code" href="../../d4/da8/group__imgcodecs.html#gabbc7ef1aa2edfaa87772f1202d67e0ce">imwrite</a>(result_name, pano);</div><div class="line">    cout &lt;&lt; <span class="stringliteral">&quot;stitching completed successfully\n&quot;</span> &lt;&lt; result_name &lt;&lt; <span class="stringliteral">&quot; saved!&quot;</span>;</div><div class="line">    <span class="keywordflow">return</span> EXIT_SUCCESS;</div><div class="line">}</div><div class="line"></div><div class="line"></div><div class="line"><span class="keywordtype">void</span> printUsage(<span class="keywordtype">char</span>** argv)</div><div class="line">{</div><div class="line">    cout &lt;&lt;</div><div class="line">         <span class="stringliteral">&quot;Images stitcher.\n\n&quot;</span> &lt;&lt; <span class="stringliteral">&quot;Usage :\n&quot;</span> &lt;&lt; argv[0] &lt;&lt;<span class="stringliteral">&quot; [Flags] img1 img2 [...imgN]\n\n&quot;</span></div><div class="line">         <span class="stringliteral">&quot;Flags:\n&quot;</span></div><div class="line">         <span class="stringliteral">&quot;  --d3\n&quot;</span></div><div class="line">         <span class="stringliteral">&quot;      internally creates three chunks of each image to increase stitching success\n&quot;</span></div><div class="line">         <span class="stringliteral">&quot;  --mode (panorama|scans)\n&quot;</span></div><div class="line">         <span class="stringliteral">&quot;      Determines configuration of stitcher. The default is &#39;panorama&#39;,\n&quot;</span></div><div class="line">         <span class="stringliteral">&quot;      mode suitable for creating photo panoramas. Option &#39;scans&#39; is suitable\n&quot;</span></div><div class="line">         <span class="stringliteral">&quot;      for stitching materials under affine transformation, such as scans.\n&quot;</span></div><div class="line">         <span class="stringliteral">&quot;  --output &lt;result_img&gt;\n&quot;</span></div><div class="line">         <span class="stringliteral">&quot;      The default is &#39;result.jpg&#39;.\n\n&quot;</span></div><div class="line">         <span class="stringliteral">&quot;Example usage :\n&quot;</span> &lt;&lt; argv[0] &lt;&lt; <span class="stringliteral">&quot; --d3 --mode scans img1.jpg img2.jpg\n&quot;</span>;</div><div class="line">}</div><div class="line"></div><div class="line"></div><div class="line"><span class="keywordtype">int</span> parseCmdArgs(<span class="keywordtype">int</span> argc, <span class="keywordtype">char</span>** argv)</div><div class="line">{</div><div class="line">    <span class="keywordflow">if</span> (argc == 1)</div><div class="line">    {</div><div class="line">        printUsage(argv);</div><div class="line">        <span class="keywordflow">return</span> EXIT_FAILURE;</div><div class="line">    }</div><div class="line"></div><div class="line">    <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 1; i &lt; argc; ++i)</div><div class="line">    {</div><div class="line">        <span class="keywordflow">if</span> (<span class="keywordtype">string</span>(argv[i]) == <span class="stringliteral">&quot;--help&quot;</span> || <span class="keywordtype">string</span>(argv[i]) == <span class="stringliteral">&quot;/?&quot;</span>)</div><div class="line">        {</div><div class="line">            printUsage(argv);</div><div class="line">            <span class="keywordflow">return</span> EXIT_FAILURE;</div><div class="line">        }</div><div class="line">        <span class="keywordflow">else</span> <span class="keywordflow">if</span> (<span class="keywordtype">string</span>(argv[i]) == <span class="stringliteral">&quot;--d3&quot;</span>)</div><div class="line">        {</div><div class="line">            divide_images = <span class="keyword">true</span>;</div><div class="line">        }</div><div class="line">        <span class="keywordflow">else</span> <span class="keywordflow">if</span> (<span class="keywordtype">string</span>(argv[i]) == <span class="stringliteral">&quot;--output&quot;</span>)</div><div class="line">        {</div><div class="line">            result_name = argv[i + 1];</div><div class="line">            i++;</div><div class="line">        }</div><div class="line">        <span class="keywordflow">else</span> <span class="keywordflow">if</span> (<span class="keywordtype">string</span>(argv[i]) == <span class="stringliteral">&quot;--mode&quot;</span>)</div><div class="line">        {</div><div class="line">            <span class="keywordflow">if</span> (<span class="keywordtype">string</span>(argv[i + 1]) == <span class="stringliteral">&quot;panorama&quot;</span>)</div><div class="line">                mode = Stitcher::PANORAMA;</div><div class="line">            <span class="keywordflow">else</span> <span class="keywordflow">if</span> (<span class="keywordtype">string</span>(argv[i + 1]) == <span class="stringliteral">&quot;scans&quot;</span>)</div><div class="line">                mode = Stitcher::SCANS;</div><div class="line">            <span class="keywordflow">else</span></div><div class="line">            {</div><div class="line">                cout &lt;&lt; <span class="stringliteral">&quot;Bad --mode flag value\n&quot;</span>;</div><div class="line">                <span class="keywordflow">return</span> EXIT_FAILURE;</div><div class="line">            }</div><div class="line">            i++;</div><div class="line">        }</div><div class="line">        <span class="keywordflow">else</span></div><div class="line">        {</div><div class="line">            <a class="code" href="../../d3/d63/classcv_1_1Mat.html">Mat</a> img = <a class="code" href="../../d4/da8/group__imgcodecs.html#ga288b8b3da0892bd651fce07b3bbd3a56">imread</a>(<a class="code" href="../../d6/dba/group__core__utils__samples.html#ga3a33b00033b46c698ff6340d95569c13">samples::findFile</a>(argv[i]));</div><div class="line">            <span class="keywordflow">if</span> (img.<a class="code" href="../../d3/d63/classcv_1_1Mat.html#abbec3525a852e77998aba034813fded4">empty</a>())</div><div class="line">            {</div><div class="line">                cout &lt;&lt; <span class="stringliteral">&quot;Can&#39;t read image &#39;&quot;</span> &lt;&lt; argv[i] &lt;&lt; <span class="stringliteral">&quot;&#39;\n&quot;</span>;</div><div class="line">                <span class="keywordflow">return</span> EXIT_FAILURE;</div><div class="line">            }</div><div class="line"></div><div class="line">            <span class="keywordflow">if</span> (divide_images)</div><div class="line">            {</div><div class="line">                <a class="code" href="../../d2/d44/classcv_1_1Rect__.html">Rect</a> rect(0, 0, img.<a class="code" href="../../d3/d63/classcv_1_1Mat.html#aa3e5a47585c9ef6a0842556739155e3e">cols</a> / 2, img.<a class="code" href="../../d3/d63/classcv_1_1Mat.html#abed816466c45234254d25bc59c31245e">rows</a>);</div><div class="line">                imgs.push_back(img(rect).clone());</div><div class="line">                rect.x = img.<a class="code" href="../../d3/d63/classcv_1_1Mat.html#aa3e5a47585c9ef6a0842556739155e3e">cols</a> / 3;</div><div class="line">                imgs.push_back(img(rect).clone());</div><div class="line">                rect.x = img.<a class="code" href="../../d3/d63/classcv_1_1Mat.html#aa3e5a47585c9ef6a0842556739155e3e">cols</a> / 2;</div><div class="line">                imgs.push_back(img(rect).clone());</div><div class="line">            }</div><div class="line">            <span class="keywordflow">else</span></div><div class="line">                imgs.push_back(img);</div><div class="line">        }</div><div class="line">    }</div><div class="line">    <span class="keywordflow">return</span> EXIT_SUCCESS;</div><div class="line">}</div></div><!-- fragment --><h2>Explanation </h2>
<p>The most important code part is:</p>
<div class="fragment"><div class="line">    Mat pano;</div><div class="line">    Ptr&lt;Stitcher&gt; stitcher = Stitcher::create(mode);</div><div class="line">    Stitcher::Status status = stitcher-&gt;stitch(imgs, pano);</div><div class="line"></div><div class="line">    <span class="keywordflow">if</span> (status != Stitcher::OK)</div><div class="line">    {</div><div class="line">        cout &lt;&lt; <span class="stringliteral">&quot;Can&#39;t stitch images, error code = &quot;</span> &lt;&lt; int(status) &lt;&lt; endl;</div><div class="line">        <span class="keywordflow">return</span> EXIT_FAILURE;</div><div class="line">    }</div></div><!-- fragment --><p> A new instance of stitcher is created and the <a class="el" href="../../d2/d8d/classcv_1_1Stitcher.html#a37ee5bacf229e9d0fb9f97c8f5ed1acd">cv::Stitcher::stitch</a> will do all the hard work.</p>
<p><a class="el" href="../../d2/d8d/classcv_1_1Stitcher.html#a308a47865a1f381e4429c8ec5e99549f">cv::Stitcher::create</a> can create stitcher in one of the predefined configurations (argument <code>mode</code>). See <a class="el" href="../../d2/d8d/classcv_1_1Stitcher.html#a114713924ec05a0309f4df7e918c0324">cv::Stitcher::Mode</a> for details. These configurations will setup multiple stitcher properties to operate in one of predefined scenarios. After you create stitcher in one of predefined configurations you can adjust stitching by setting any of the stitcher properties.</p>
<p>If you have cuda device <a class="el" href="../../d2/d8d/classcv_1_1Stitcher.html">cv::Stitcher</a> can be configured to offload certain operations to GPU. If you prefer this configuration set <code>try_use_gpu</code> to true. OpenCL acceleration will be used transparently based on global OpenCV settings regardless of this flag.</p>
<p>Stitching might fail for several reasons, you should always check if everything went good and resulting pano is stored in <code>pano</code>. See <a class="el" href="../../d2/d8d/classcv_1_1Stitcher.html#a507409ce9435dd89857469d12ec06b45">cv::Stitcher::Status</a> documentation for possible error codes.</p>
<h2>Camera models </h2>
<p>There are currently 2 camera models implemented in stitching pipeline.</p>
<ul>
<li><em>Homography model</em> expecting perspective transformations between images implemented in <a class="el" href="../../d4/d26/classcv_1_1detail_1_1BestOf2NearestMatcher.html">cv::detail::BestOf2NearestMatcher</a> <a class="el" href="../../db/d3e/classcv_1_1detail_1_1HomographyBasedEstimator.html" title="Homography based rotation estimator. ">cv::detail::HomographyBasedEstimator</a> <a class="el" href="../../dc/d54/classcv_1_1detail_1_1BundleAdjusterReproj.html" title="Implementation of the camera parameters refinement algorithm which minimizes sum of the reprojection ...">cv::detail::BundleAdjusterReproj</a> <a class="el" href="../../da/d7c/classcv_1_1detail_1_1BundleAdjusterRay.html" title="Implementation of the camera parameters refinement algorithm which minimizes sum of the distances bet...">cv::detail::BundleAdjusterRay</a></li>
<li><em>Affine model</em> expecting affine transformation with 6 DOF or 4 DOF implemented in <a class="el" href="../../d3/dda/classcv_1_1detail_1_1AffineBestOf2NearestMatcher.html">cv::detail::AffineBestOf2NearestMatcher</a> <a class="el" href="../../d0/df2/classcv_1_1detail_1_1AffineBasedEstimator.html" title="Affine transformation based estimator. ">cv::detail::AffineBasedEstimator</a> <a class="el" href="../../d6/d8d/classcv_1_1detail_1_1BundleAdjusterAffine.html" title="Bundle adjuster that expects affine transformation represented in homogeneous coordinates in R for ea...">cv::detail::BundleAdjusterAffine</a> <a class="el" href="../../d4/dbb/classcv_1_1detail_1_1BundleAdjusterAffinePartial.html" title="Bundle adjuster that expects affine transformation with 4 DOF represented in homogeneous coordinates ...">cv::detail::BundleAdjusterAffinePartial</a> <a class="el" href="../../d4/dd7/classcv_1_1AffineWarper.html" title="Affine warper factory class. ">cv::AffineWarper</a></li>
</ul>
<p>Homography model is useful for creating photo panoramas captured by camera, while affine-based model can be used to stitch scans and object captured by specialized devices.</p>
<dl class="section note"><dt>Note</dt><dd>Certain detailed settings of <a class="el" href="../../d2/d8d/classcv_1_1Stitcher.html">cv::Stitcher</a> might not make sense. Especially you should not mix classes implementing affine model and classes implementing Homography model, as they work with different transformations.</dd></dl>
<h2>Try it out </h2>
<p>If you enabled building samples you can found binary under <code>build/bin/cpp-example-stitching</code>. This example is a console application, run it without arguments to see help. <code>opencv_extra</code> provides some sample data for testing all available configurations.</p>
<p>to try panorama mode run: </p><div class="fragment"><div class="line">./cpp-example-stitching --mode panorama &lt;path to opencv_extra&gt;/testdata/stitching/boat*</div></div><!-- fragment --> <div class="image">
<img src="../../boat.jpg" alt="boat.jpg"/>
</div>
<p>to try scans mode run (dataset from home-grade scanner): </p><div class="fragment"><div class="line">./cpp-example-stitching --mode scans &lt;path to opencv_extra&gt;/testdata/stitching/newspaper*</div></div><!-- fragment --> <div class="image">
<img src="../../newspaper.jpg" alt="newspaper.jpg"/>
</div>
<p>or (dataset from professional book scanner): </p><div class="fragment"><div class="line">./cpp-example-stitching --mode scans &lt;path to opencv_extra&gt;/testdata/stitching/budapest*</div></div><!-- fragment --> <div class="image">
<img src="../../budapest.jpg" alt="budapest.jpg"/>
</div>
<dl class="section note"><dt>Note</dt><dd>Examples above expects POSIX platform, on windows you have to provide all files names explicitly (e.g. <code>boat1.jpg</code> <code>boat2.jpg</code>...) as windows command line does not support <code>*</code> expansion.</dd></dl>
<h2>Stitching detailed (python opencv &gt;4.0.1) </h2>
<p>If you want to study internals of the stitching pipeline or you want to experiment with detailed configuration you can use stitching_detailed source code available in C++ or python</p>
<h4>stitching_detailed</h4>
 <div class='newInnerHTML' title='cpp' style='display: none;'>C++</div><div class='toggleable_div label_cpp' style='display: none;'><p> <a href="https://raw.githubusercontent.com/opencv/opencv/master/samples/cpp/stitching_detailed.cpp">stitching_detailed.cpp</a> </p> </div>  <div class='newInnerHTML' title='python' style='display: none;'>Python</div><div class='toggleable_div label_python' style='display: none;'><p> <a href="https://raw.githubusercontent.com/opencv/opencv/master/samples/python/stitching_detailed.py">stitching_detailed.py</a> </p> </div> <p>stitching_detailed program uses command line to get stitching parameter. Many parameters exists. Above examples shows some command line parameters possible :</p>
<p>boat5.jpg boat2.jpg boat3.jpg boat4.jpg boat1.jpg boat6.jpg &ndash;work_megapix 0.6 &ndash;features orb &ndash;matcher homography &ndash;estimator homography &ndash;match_conf 0.3 &ndash;conf_thresh 0.3 &ndash;ba ray &ndash;ba_refine_mask xxxxx &ndash;save_graph test.txt &ndash;wave_correct no &ndash;warp fisheye &ndash;blend multiband &ndash;expos_comp no &ndash;seam gc_colorgrad</p>
<div class="image">
<img src="../../fisheye.jpg" alt="fisheye.jpg"/>
</div>
<p>Pairwise images are matched using an homography &ndash;matcher homography and estimator used for transformation estimation too &ndash;estimator homography</p>
<p>Confidence for feature matching step is 0.3 : &ndash;match_conf 0.3. You can decrease this value if you have some difficulties to match images</p>
<p>Threshold for two images are from the same panorama confidence is 0. : &ndash;conf_thresh 0.3 You can decrease this value if you have some difficulties to match images</p>
<p>Bundle adjustment cost function is ray &ndash;ba ray</p>
<p>Refinement mask for bundle adjustment is xxxxx ( &ndash;ba_refine_mask xxxxx) where 'x' means refine respective parameter and '_' means don't. Refine one, and has the following format: fx,skew,ppx,aspect,ppy</p>
<p>Save matches graph represented in DOT language to test.txt ( &ndash;save_graph test.txt) : Labels description: Nm is number of matches, Ni is number of inliers, C is confidence</p>
<div class="image">
<img src="../../gvedit.jpg" alt="gvedit.jpg"/>
</div>
<p>Perform wave effect correction is no (&ndash;wave_correct no)</p>
<p>Warp surface type is fisheye (&ndash;warp fisheye)</p>
<p>Blending method is multiband (&ndash;blend multiband)</p>
<p>Exposure compensation method is not used (&ndash;expos_comp no)</p>
<p>Seam estimation estimator is Minimum graph cut-based seam (&ndash;seam gc_colorgrad)</p>
<p>you can use those arguments on command line too :</p>
<p>boat5.jpg boat2.jpg boat3.jpg boat4.jpg boat1.jpg boat6.jpg &ndash;work_megapix 0.6 &ndash;features orb &ndash;matcher homography &ndash;estimator homography &ndash;match_conf 0.3 &ndash;conf_thresh 0.3 &ndash;ba ray &ndash;ba_refine_mask xxxxx &ndash;wave_correct horiz &ndash;warp compressedPlaneA2B1 &ndash;blend multiband &ndash;expos_comp channels_blocks &ndash;seam gc_colorgrad</p>
<p>You will get :</p>
<div class="image">
<img src="../../compressedPlaneA2B1.jpg" alt="compressedPlaneA2B1.jpg"/>
</div>
<p>For images captured using a scanner or a drone ( affine motion) you can use those arguments on command line :</p>
<p>newspaper1.jpg newspaper2.jpg &ndash;work_megapix 0.6 &ndash;features surf &ndash;matcher affine &ndash;estimator affine &ndash;match_conf 0.3 &ndash;conf_thresh 0.3 &ndash;ba affine &ndash;ba_refine_mask xxxxx &ndash;wave_correct no &ndash;warp affine</p>
<div class="image">
<img src="../../affinepano.jpg" alt="affinepano.jpg"/>
</div>
<p>You can find all images in <a href="https://github.com/opencv/opencv_extra/tree/master/testdata/stitching">https://github.com/opencv/opencv_extra/tree/master/testdata/stitching</a> </p>
</div></div><!-- contents -->
<!-- HTML footer for doxygen 1.8.6-->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated on Fri Apr 2 2021 11:36:37 for OpenCV by &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="../../doxygen.png" alt="doxygen"/>
</a> 1.8.13
</small></address>
<script type="text/javascript">
//<![CDATA[
addTutorialsButtons();
//]]>
</script>
</body>
</html>
